/*
ID: icerupt1
PROG: lamps
LANG: C++11
*/
#include <fstream>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

std::ifstream fin {"lamps.in" };
std::ofstream fout{"lamps.out"};

std::vector<int> final_on;
std::vector<int> final_off;
int n, c;


int bit_count_one(int x)
{
	x = (x & 0x55555555) + ((x>>1) & 0x55555555);
	x = (x & 0x33333333) + ((x>>2) & 0x33333333);
	x = (x & 0x0F0F0F0F) + ((x>>4) & 0x0F0F0F0F);
	x = (x & 0x00FF00FF) + ((x>>8) & 0x00FF00FF);
	x = (x & 0x0000FFFF) + ((x>>16)& 0x0000FFFF);
	return x;
}

bool judge(int op, int count)
{
	int count_one = bit_count_one(op);
	return (count >= count_one && !((count - count_one)&1));
}

bool opt_pos(int pos, int op)
{
	if (op == 0) return true;
	if (op == 1 && (pos&1)) return true;
	if (op == 2 && !(pos&1)) return true;
	return ((op == 3) && (pos - 1) % 3 == 0);
}

void opt(std::string & s, int op)
{
	int len = s.size();
	for (int i = 0; i < len; i++)
		if (opt_pos(i+1, op)) (s[i] == '0') ? (s[i] = '1') : (s[i] = '0');
}

bool check(std::string const& s)
{
	for (auto i : final_on) if (s[i-1] != '1') return false;
	for (auto i : final_off) if (s[i-1] != '0') return false;
	return true;
}

int main()
{
	fin >> n >> c;
	for (int tmp; fin >> tmp && tmp != -1; ) final_on.push_back(tmp);
	for (int tmp; fin >> tmp && tmp != -1; ) final_off.push_back(tmp);

	std::vector<std::string> ans;
	for (int i = 0 ; i < 16; i++) {
		if (!judge(i, c)) continue;
		std::string first_state(n, '1');
		for (int j = 0; j < 4; j++)
			if ((1<<j)&i) opt(first_state, j);
		if (check(first_state)) ans.push_back(first_state);
	}

	std::sort(ans.begin(), ans.end());
	if (ans.empty()) {
		std::cout << "IMPOSSIBLE\n";
		fout << "IMPOSSIBLE\n";
		return 0;
	}
	std::cout << ans[0] << '\n';
	fout << ans[0] << '\n';
	for (int i = 1; i < (int)ans.size(); i++)
		if (ans[i] != ans[i-1]) {
			std::cout << ans[i] << '\n';
			fout << ans[i] << '\n';
		}
}
